import KCharts from '@/components/k-charts/k-charts.vue';
import PageListContainer from '@/components/base-page-container/page-list-container.vue';
import * as KDialogComponents from '@/components/k-dialog/index';
import * as ElIcons from '@element-plus/icons-vue';
import KEmpty from '@/components/k-empty/index.vue';
import KIcon from './k-icon/index.vue';
const components: any = {
  KIcon,
  KCharts,
  PageListContainer,
  KEmpty,
  ...KDialogComponents
};
export default {
  install: (app: any) => {
    for (const key in components) {
      if (Object.prototype.hasOwnProperty.call(components, key)) {
        app.component(key, components[key]);
      }
    }

    for (const [key, component] of Object.entries(ElIcons)) {
      app.component('elm' + key, component); // 增加命名空间 elm
    }

    // TODO: 后面删掉

    // 将element-plus提供图标注册为全局组件
    for (const [key, component] of Object.entries(ElIcons)) {
      if ('Menu' !== key) {// 如果不是图标组件不是Menu，就跳过，否则加上ICon的后缀
        app.component(key, component);
      } else {
        app.component('Icon' + key, component);
      }
    }
  }
};
